package JAVATest;

import java.util.Scanner;

/**
 * ClassName:Text_014
 * Package:JAVATest
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/13-0:09
 * @Version:v1.0
 */
public class Text_014 {
    public static void main(String[] args) {
        int []scoresArr= getScores();
        for (int i = 0; i < scoresArr.length; i++) {
            System.out.print(scoresArr[i] + " ");
        }
        double avg = 0.0;
        avg = getSum(scoresArr)/(scoresArr.length-2);
        System.out.print("\n");
        System.out.println("选手的最终的分是:"+avg);


    }
    public static int getMax(int []scoresArr){
        int max = scoresArr[0];
        for (int i = 0; i < scoresArr.length; i++) {
            if(scoresArr[i]>max){
                max=scoresArr[i];
            }
        }
        return max;
    }
    public static int getMin(int []scoresArr){
        int min = scoresArr[0];
        for (int i = 0; i < scoresArr.length; i++) {
            if(scoresArr[i]<min){
                min = scoresArr[i];
            }
        }
        return min;
    }
    public static double getSum(int []scoresArr){
        int sum = 0;
        for (int i = 0; i < scoresArr.length; i++) {
            sum += scoresArr[i];
        }
        sum = sum - getMax(scoresArr)- getMin(scoresArr);
        return sum;
    }

    public static int[] getScores(){
        int[] scores=new int [6];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < scores.length;) {
            System.out.println("请输入评委的打分:");
            int score=sc.nextInt();
            if(score>=0 && score<=100){
                scores[i]=score;
                i++;
            }else{
                System.out.println("成绩超出范围,请重新输入,当前的i=" + i);
            }
        }
        return scores;
    }

}
